<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>RegExp lastIndex</title>
</head>
<body>
<h3>RegExp lastIndex 方法</h3>
<script>
var str="The rain in Spain stays mainly in the plain";
var patt1=/ain/g;

while (patt1.test(str)==true) 
{
	document.write("'ain' found. Index now at: "+patt1.lastIndex);
	document.write("<br>");
}
</script>
</body>
</html>
